//
//  VectorClass2.hpp
//  Practice11
//
//  Created by 赵世杰 on 2020/7/26.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#ifndef VectorClass2_hpp
#define VectorClass2_hpp

#include <stdio.h>
#include <iostream>

#endif /* VectorClass2_hpp */


namespace VECTOR2 {

class Vector2
{
public:
    enum Mode{RECT,POL};
    
private:
    double x;
    double y;
//    double mag;
//    double ang;
    
    Mode mode;
    
//    void set_mag();
//    void set_ang();
    
    
    void set_x();
    void set_y();
    
public:
    Vector2();
    Vector2(double n1,double n2,Mode form=RECT);
    void reset(double n1,double n2,Mode form=RECT);
    ~Vector2();
    double xval()const{return x;};
    double yval()const{return y;};
//    double magval()const{return mag;};
//    double angval()const{return ang;};
    
    double magval() const;
    double angval() const;
    
    void polar_mode();
    void rect_model();
    
    Vector2 operator+(const Vector2 &b)const;
    Vector2 operator-(const Vector2 &b)const;
    Vector2 operator-()const;
    Vector2 operator*(double n)const;
    
    friend Vector2 operator*(double n,const Vector2 &a);
    friend std::ostream & operator<<(std::ostream & os,const Vector2 & v);
    
    
};


}
